package repositories;

import java.util.Collection;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import domain.Bid;

@Repository
public interface BidRepository extends JpaRepository<Bid, Integer> {
	@Query("select b from Bid b where b.amount.amount=(select max(bb.amount.amount) from Bid bb)")
	Collection<Bid> findByHigeshtBid();
	
	@Query("select b from Bid b where b.auction.id = ?1")
	Collection<Bid> findBidsByAuctionId(int auctionId);
	
	@Query("select b from Bid b where b.customer.id = ?1")
	Collection<Bid> findBidsByCustomerId(int customerId);
	
	@Query("select b from Bid b where b.customer.id = ?1 and b.auction.id=?2")
	Bid findBidByCustomerIdAndAuctionId(int customerId, int auctionId);

}
